package com.yanqu.road.server.cmd.activity.summergames.fromcross;

import com.yanqu.road.entity.log.summergames.LogSummerGamesExchange;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SummerGamesProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SUMMER_GAMES_EXCHANGE_REFUSE_FROM_CROSS, desc = "拒绝(跨服返回)")
public class SummerGamesRefuseFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SummerGamesProto.CrossSummerGamesRefuseApplyRespMsg respMsg = SummerGamesProto.CrossSummerGamesRefuseApplyRespMsg.parseFrom(packet.getBytes());

        player.sendPacket(Protocol.U_SUMMER_GAMES_REFUSE_APPLY, SummerGamesProto.SummerGamesRefuseApplyRespMsg.newBuilder().setRet(respMsg.getRet()));

        //日志
        for (SummerGamesProto.SummerGamesExchangeInfoTemp temp : respMsg.getInfoList()) {
            AutoLogMgr.add(new LogSummerGamesExchange(
                    respMsg.getActivityId(),
                    packet.getPlayerId(),
                    temp.getId(),
                    1,
                    temp.getPlayerId(),
                    0,
                    temp.getProvideId(),
                    temp.getType()
            ));
        }

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
